package com.library.controller;

import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author weiwu
 * @description 测试pdf
 * @date 2018/10/7 15:39
 */
@Controller
public class pdfController {

    @GetMapping ( value = "/viewPdf/{pdfURl}", produces = "application/pdf" )
    @ResponseBody
    public ClassPathResource viewPdf( @PathVariable String pdfURl ) {
        String filepath = "pdf/" + pdfURl + ".pdf";
        ClassPathResource resource = new ClassPathResource(filepath);
        return resource;
    }

//    @RequestMapping ( "/demopdf" )
//    public String demotPdf() {
//        return "demo/pdfDemo";
//    }

}
